package typeConversion;

import org.springframework.beans.BeanUtils;
import typeConversion.typeDo.MerchantCouponConfigBO;
import typeConversion.typeDo.MerchantCouponConfigDTO;
import utils.BeanConv;

/**
 * @author yangjicong
 * @date 2022/3/2
 */
public class Convert {

	public static void main(String[] args) {
		//使用spring的BeanUtils 来 copy属性
		 copyDtoToBo1();
		//使用封装的BeanConv copy属性
		//copyDtoToBo2();



	}


	public static void copyDtoToBo1(){
		MerchantCouponConfigDTO dto = getDTO();
		MerchantCouponConfigBO merchantCouponConfigBO = new MerchantCouponConfigBO();
		BeanUtils.copyProperties(dto, merchantCouponConfigBO);
		System.out.println("merchantCouponConfigBO = " + merchantCouponConfigBO);
	}

	public static void copyDtoToBo2(){
		MerchantCouponConfigDTO dto = getDTO();
		MerchantCouponConfigBO merchantCouponConfigBO = new MerchantCouponConfigBO();
		BeanConv.toBean(dto,merchantCouponConfigBO);
		System.out.println("merchantCouponConfigBO = " + merchantCouponConfigBO);
	}




	public static MerchantCouponConfigDTO getDTO(){

		MerchantCouponConfigDTO merchantCouponConfigDTO = new MerchantCouponConfigDTO();
		merchantCouponConfigDTO.setMerchantCode("123");
		merchantCouponConfigDTO.setProvinceCode("222");
		merchantCouponConfigDTO.setCityCode("333");
		merchantCouponConfigDTO.setProductNo("4444");
		return merchantCouponConfigDTO;
	}

}
